package zhieasy.cn.service.initiation.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import zhieasy.cn.model.common.StudentUser;
import zhieasy.cn.model.common.TeacherUser;
import zhieasy.cn.model.initiation.AdminCollege;
import zhieasy.cn.persistence.mapper.common.StudentUserMapper;
import zhieasy.cn.persistence.mapper.common.TeacherUserMapper;
import zhieasy.cn.persistence.mapper.initiation.AdminCollegeMapper;
import zhieasy.cn.service.initiation.AdminCollegeService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author sofency
 * @date 2020/8/2 7:36
 * @package IntelliJ IDEA
 * @description
 */
@Service
public class AdminCollegeServiceImpl implements AdminCollegeService {

    @Autowired
    StudentUserMapper studentUserMapper;

    @Autowired
    private AdminCollegeMapper adminCollegeMapper;

    /**
     * 根据管理员的openId进行查询
     * @param openId
     * @return
     */
    @Override
    public AdminCollege loginByManager(String openId) {
        Map<String,Object> map = new HashMap<>(1,1);
        map.put("open_id",openId);
        List<AdminCollege> adminCollege = adminCollegeMapper.selectByMap(map);
        if(!CollectionUtils.isEmpty(adminCollege)){
            return adminCollege.get(0);
        }else{
            return null;
        }
    }
}
